import React from 'react'
import { Form, Input, InputNumber, Switch, Checkbox, message } from 'antd'
import request from '@/utils/request'
const { TextArea } = Input
export default (props: any) => {
    const { saveForm, close, id, getList } = props

    const onFinish = (values: any) => {
        request(`/store/level-save/${id}`, {
            method: 'POST',
            data: { ...values },
        }).then((result) => {
            if (result.code !== 200) {
                message.warning(result.message)
                return
            }
            message.success(result.message, 1, () => {
                getList()
                close()
            })
        })
    }
    const dataList = [
        { title: "组合套餐", desc: "组合套餐活动功能", url: "http://uniapp.b2b2c.niuteam.cn/addon/bundling/icon.png" },
        { title: "优惠卷", desc: "会员优惠券功能", url: "http://uniapp.b2b2c.niuteam.cn/addon/coupon/icon.png" },
        { title: "限时折扣", desc: "限时折扣功能", url: "http://uniapp.b2b2c.niuteam.cn/addon/discount/icon.png" },
        { title: "团购", desc: "团购活动", url: "http://uniapp.b2b2c.niuteam.cn/addon/groupbuy/icon.png" },
        { title: "满减活动", desc: "满减送活动", url: "http://uniapp.b2b2c.niuteam.cn/addon/manjian/icon.png" },
        { title: "拼团", desc: "拼团活动", url: "http://uniapp.b2b2c.niuteam.cn/addon/pintuan/icon.png" },
        { title: "限时秒杀", desc: "限时秒杀功能", url: "http://uniapp.b2b2c.niuteam.cn/addon/seckill/icon.png" },
        { title: "专题活动", desc: "专题活动功能", url: "http://uniapp.b2b2c.niuteam.cn/addon/topic/icon.png" },
    ];
    return (
        <Form
            labelCol={{ span: 3 }}
            wrapperCol={{ span: 19 }}
            form={saveForm}
            onFinish={onFinish}
        >
            <Form.Item label="等级名称" name="title" required rules={[{ required: true, message: '等级名称不能为空' }]}>
                <Input />
            </Form.Item>
            <Form.Item label="是否自营" name="is_own" valuePropName="checked">
                <Switch />
            </Form.Item>
            <Form.Item label="年费" name="annual_fee" help="年费不能小于0，可保留两位小数">
                <InputNumber />
            </Form.Item>
            <Form.Item label="描述" name="describe">
                <TextArea rows={3} />
            </Form.Item>
            <Form.Item label="营销模块">
                <ul style={{ display: "flex", flexWrap: "wrap", justifyContent: "space-between", margin: 0, padding: 0 }}>
                    {
                        dataList.map((item: any, inx: number) => {
                            return (
                                <li key={inx} style={{
                                    width: "24%", border: "1px solid #E5E5E5", marginBottom: "20px", padding: "10px",
                                    display: "flex", justifyContent: "space-between", alignItems: "center"
                                }}>
                                    <div style={{ display: "flex" }}>
                                        <img src={item.url} alt="" style={{ width: "56px", height: "56px" }} />
                                        <div style={{ display: "flex", flexDirection: "column", justifyContent: "center", marginLeft: "6px" }}>
                                            <span>{item.title}</span>
                                            <small style={{ color: "#999" }}>{item.desc}</small>
                                        </div>
                                    </div>

                                    <Checkbox />
                                </li>
                            )
                        })
                    }
                </ul>
            </Form.Item>
        </Form>
    )
}